<script setup>
import { ref, defineOptions } from 'vue'
import TopTitle from "@/components/TopTitle.vue"
import { smallView } from '@/api/getAxios_2.ts'

const smallview = ref([])
let pageNo = ref('1')
smallView('1').then((res) => {
    // console.log(res);
    smallview.value = res.data.data
})


// 改变万和亿的方法
const changeNum = (num) => {
    if(num / 10000 >= 10000) {
        return (num / 100000000).toFixed(1) + '亿人气值'
    } else {
        return (num / 10000).toFixed(1) + '万人气值'
    }
}

</script>
<template>
    <!-- <div class="box" @scroll="scrollHandler($event)"> -->
    <div class="box">
        <TopTitle :flag="true" name="小编推荐"></TopTitle>
        <div class="city-msg">
            <ul class="total">
                <li v-for="item in smallview" @click="$router.push(`/BookInfo?storyId=${item.storyId}`)">
                    <div class="faceimg">
                        <img :src="item.facePic" alt="">
                    </div>
                    <div class="info">
                        <p class="name">{{ item.nickName }}</p>
                        <p class="detail">编辑点评：{{ item.storyComment }}</p>
                        <div class="type">
                            <img :src="item.cover" alt="">
                            <div class="story">
                                <h3 class="storyName">{{ item.storyName }}</h3>
                                <span class="storyType">{{ item.authorName }} | {{ item.storyType }}</span>
                            </div>
                            <span class="person">{{ changeNum(item.fireValue) }}</span>
                        </div>
                    </div>
                </li>
            </ul>
        </div>
    </div>
</template>

<style scoped lang='less'>
.box {
    height: 100vh;
    overflow: scroll;

    &::-webkit-scrollbar {
        display: none;
    }
}

.city-msg {
    // height: 158vw;
    background-color: #fff;
    margin-bottom: 15px;

    ul {
        display: flex;
        flex-direction: column;
        background-color: #fff;

        li {
            padding: 10px;
            height: 40vw;
            display: flex;
            border-bottom: 1px solid #eee;
            .faceimg {
                width: 10vw;
                height: 100%;
                // background-color: pink;
                margin: 0 10px;
                img {
                    width: 30px;
                    height: 30px;
                    border-radius: 50%;
                }
            }
            .info {
                font-size: 14px;
                .name {
                    font-size: 16px;
                    font-weight: bold;
                    margin-bottom: 5px;
                }
                .detail {
                    color: #aaa9ac;
                    margin-bottom: 5px;

                }
                .type {
                    display: flex;
                    background-color: #eee;
                    width: 77vw;
                    padding: 10px;
                    align-items: center;
                    img {
                        width: 12vw;
                        margin-right: 10px;
                    }
                    .story {
                        width: 34vw;
                        .storyName {
                            font-size: 16px;
                            font-weight: bold;
                            margin-bottom: 5px;
                        }
                        .storyType {
                            color: #99989c;
                            font-size: 12px;
                        }
                    }
                    .person {
                        width: 100px;
                        text-align: right;
                        color: #ccae59;
                    }
                }
            }
            
            

        }
    }
}
</style>